home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000824-20010305 / 000216_news@columbia.edu _Tue Jan 23 09:13:33 2001.msg < prev    next >
Internet Message Format  |  2020-01-01  |  17KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from watsun.cc.columbia.edu (watsun.cc.columbia.edu [128.59.39.2])
  3.     by fozimane.cc.columbia.edu (8.9.3/8.9.3) with ESMTP id JAA14879
  4.     for <kermit.misc@cpunix.cc.columbia.edu>; Tue, 23 Jan 2001 09:13:33 -0500 (EST)
  5. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  6.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id JAA26365
  7.     for <kermit.misc@watsun.cc.columbia.edu>; Tue, 23 Jan 2001 09:13:32 -0500 (EST)
  8. Received: (from news@localhost)
  9.     by newsmaster.cc.columbia.edu (8.9.3/8.9.3) id JAA03566
  10.     for kermit.misc@watsun.cc.columbia.edu; Tue, 23 Jan 2001 09:01:40 -0500 (EST)
  11. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  12. From: <Use-Author-Address-Header@[127.1]>
  13. Subject: Lynx/Kermit Coordination Part I ( Corrected )
  14. Message-ID: <E14L3yc-0000VT-00@dxmcgyver>
  15. Date: Tue, 23 Jan 2001 05:59:14 -0800
  16. Organization: mail2news@nym.alias.net
  17. To: kermit.misc@columbia.edu
  18.  
  19. ( Correcting some typos, and plain old mistakes. )
  20.  
  21. Lynx/Kermit Coordination Part I
  22.  
  23. The version of ckermit2.txt that I currently have,
  24. (http://www.columbia.edu/kermit/ckermit2.html#x1.3.2)
  25. in the Lynx section on invoking C-Kermit from your browser (1.3.2)
  26. it states that 'As far as we know, this can be done only at compile time.'
  27. If you consider what happens when you hit return to be 'invoking',
  28. stictly speaking this is true.
  29. *If* your version of Lynx is compiled with general External support,
  30. however, in your /etc/lynx.cfg file there should be some lines like:
  31.  
  32.  
  33. #***Must be compiled with USE_EXTERNALS to enable EXTERN ***
  34. KEYMAP:.:EXTERN                # Run external program with url
  35. #   or possibly:
  36. KEYMAP:,:EXTERN         # run EXTERNAL with URL.  added by d.e.l.
  37.  
  38.  
  39. Make sure one of these is uncommented (no preceeding '#'), 
  40. or add the lines if necessary.
  41. These should be located in a general set of Keymaps, with a lot of
  42. other similar statements.  The defaults may be commented out.
  43.  
  44. Later in the file there will be a section called EXTERNAL.
  45. (Note that it is 'EXTERN' in the Keymap section, but
  46. the commands are assigned in the 'EXTERNAL' section.)
  47.  
  48. There you should have some lines:
  49.  
  50. USE_EXTERNALS:TRUE
  51. EXTERNAL:ftp:FTP  %s &:TRUE
  52. #  Where FTP is created by:
  53. #  ln -s  kermit  FTP
  54. #  when kermit is C-Kermit 7.1+
  55. EXTERNAL:http:wget -P ~/download -q %s &:TRUE
  56. #  This could even be another browser for HTTPs, instead of wget
  57. EXTERNAL:telnet:kermit -J %s:TRUE
  58. EXTERNAL:iksd:kermit  %s:1649 :TRUE
  59. #  (or)
  60. EXTERNAL:iksd:IKSget  %s & :TRUE
  61.  
  62. The only ones needed for running kermit are the 'USE_EXTERNALS:TRUE'
  63. and the lines with kermit, iksd or FTP in them.  The other, I include 
  64. simply to show a typical other external program that could be 
  65. defined.  Again, make sure that there is no preceeding '#' on
  66. the line that would comment it out and render the line inoperative.
  67.  
  68. Now, when you hit return at a focused link, the default behavior of
  69. Lynx will result as typical - for instance if a 'telnet://aztec2.asu.edu'
  70. link the conventional and less capable telnet program will be invoked.
  71. If however, you hit '.' (or whatever you chose in the Keymap statement), 
  72. C-Kermit will be invoked instead.
  73. (Similarly, over an http link, '.' will in the case shown above
  74. invoke the wget program on an http URL.)
  75. Rather than a binary executable, the program specified by the
  76. EXTERNAL statement can be a shebang script ('#!/path/interpreter'
  77. on line 1), that could present a menu
  78. of options on how to handle the URL it is passed.
  79. This is possible because of how UNIX invokes external programs giving
  80. shebang scripts pretty much equality with binary executables.
  81. (Another possibility might be Frank de Cruz's 'IKSget' script.)
  82. My personal experience is that the program specification seemed 
  83. sensitve to trailing spaces, so a little bit of experimentation may
  84. be needed.
  85. EXTERNALs can be used to enable Lynx to cope with URL schema it has no
  86. compiled in basis to deal with.  For this reason I speculativly
  87. put the 'IKSD://'  (Internet Kermit Server Daemon) example above.
  88.  
  89. In keeping with the topic of Lynx/Kermit coordination then,
  90. I include the below Kerbang script that attempts to handle
  91. (or leave space for in the future) these variations of
  92. protocols to be called externally from Lynx.
  93. It's probably overkill, and some parts haven't been
  94. thoroughly tested yet (others have), 
  95. but it should handle my needs for a while.
  96. It allows you to switch to an alternate WWW 
  97. browser in mid-surfing session for interactive
  98. sessions, gives some options for IKSD and ftp if a file or path
  99. is specified, or hops to C-Kermit if appropriate.
  100. Keep in mind that this is a work in progress,
  101. but is what I currently use.
  102.  
  103.  
  104. #!/usr/local/bin/kermit +
  105.  
  106. #  lynxbooster.ksc
  107. #
  108. #    script for external programs for Lynx web browser
  109. #    ( by D. E. Legan, 23 Jan. 2001 )
  110.  
  111. #  Requires:  Lynx, C-Kermit 7.1, 'FTP' link to kermit
  112. #             and whatever suplemental
  113. #             http user agents/browsers desired.
  114.  
  115. #  According to the Lynx documentation, it can handle
  116. #  an URL of form:
  117.  
  118. #  telnet://user:password@host:port
  119.  
  120. #  and also can handle rlogin, tn3270, tn5250 protocols similarly
  121.  
  122. #  Reading over the Lynx documentation for ftp URLs
  123. #  it can handle a form of:
  124.  
  125. #  ftp://user@host:port/path;type=[D,I,orA]
  126. #  (D,I,A = directory, binary or ASCII)
  127.  
  128. #  where user might be broken down to actually be
  129. #  a user:password.  if this followed average ftp
  130. #  conventions, then it might actually be:
  131.  
  132. #  ftp://username:user@homehost@remotehost:port/path;type=[D,I,orA]
  133.  
  134. #  Personally, I've never seen the ';type=...' part of the URL,
  135. #  so for the time being, I will ignore it, but will allot for
  136. #  some of the other complications.
  137. #  For using C-Kermit 7.1 ftp personality,  
  138. #  a soft link named 'FTP' has been made to the executable,
  139. #  to distinguish it from the plain vanilla conventional
  140. #  ftp executable.
  141.  
  142. # USAGE:
  143. #     In the lynx configuration file (typicly, lynx.cfg
  144. #     or lynx-ssl.cfg) there should be some lines
  145. #     like the following (not commented with '#' in column 1 
  146. #     though :-) ) to activate this program:
  147. #     
  148. #KEYMAP:,:EXTERN         # run EXTERNAL with URL.  added by d.e.l.
  149. #...........
  150. #USE_EXTERNALS:TRUE
  151. #...........
  152. #EXTERNAL:ftp:lynxbooster.ksc %s:TRUE
  153. #EXTERNAL:http:lynxbooster.ksc %s:TRUE
  154. #EXTERNAL:telnet:lynxbooster.ksc %s:TRUE
  155. #EXTERNAL:rlogin:lynxbooster.ksc %s:TRUE
  156. #EXTERNAL:tn3270:lynxbooster.ksc %s:TRUE
  157. #EXTERNAL:tn5250:lynxbooster.ksc %s:TRUE
  158. #EXTERNAL:iksd:lynxbooster.ksc %s:TRUE
  159.  
  160. # If not already defined, the KEYMAP value (in this case ',')
  161. # should be chosen so as not to conflict with other Lynx control
  162. # keys.
  163. # (You can have more than one character KEYMAPped to EXTERN.)
  164. # When over a link to one of these protocols, hit this key
  165. # instead of return to activate this script for the link.
  166. # The EXTERNAL statements define the protocols that external 
  167. # commands will be available for (in this case,
  168. # ftp, http, telnet, rlogin, tn3270 tn5250 and iksd), and the 
  169. # program to be run for them (in this case this script.)
  170.  
  171. # Note that if any external programs are called for
  172. # 'telnetish' protocols via pty/pipe/exec,
  173. # they may require adjustments of this script.
  174. # I don't have any of the IBM protocols on the system this
  175. # script has been developed on.
  176.  
  177.  
  178. #  Variables:
  179. #  \%a - address of URL
  180. #  \%b - user input selection flag
  181. #  \%d - raw URL
  182. #  \%f - file name stripped of directory
  183. #  \%i - path/file
  184. #  \%p - port number
  185. #  \%q - path
  186. #  \%r - protocol this script is being used for
  187. #  \%t - index used in parsing the URL as specified above
  188. #  \%u - user ID
  189. #  \%w - password
  190.  
  191.  
  192. echo {LYNX_VERSION = \$(LYNX_VERSION)}
  193. #  According to Lynx man pages, this variable is always set by Lynx
  194.  
  195. set case off
  196.  
  197. # First let's pick apart the URL for possibly usefull parts
  198.  
  199.   .\%d := \%1
  200.   .\%a := \%d
  201.   .\%r := \%a
  202.  
  203. # strip the protocol from the URL: 
  204.   .\%a := \Flop(\%a,:)  ;  strip off up to '://'
  205.   .\%a := \Fltrim(\%a,/)
  206.  
  207. # extract the protocol, up to '://':
  208.   .\%r := \Freplace(\%r,://\%a,)
  209.  
  210. #  First, we set up any URL protocol specific items:
  211. #  (this section is largely an artifact of development process
  212. #  but left in for future complications.)
  213. switch \%r {
  214.   :telnet, 
  215.   :rlogin,
  216.   :ftp, 
  217.   :http, 
  218.   :iksd,
  219.     #  this version, not much really needed here yet.  :-)
  220.     .\%c := kermit
  221.     break
  222.  
  223.     #  I haven't actually seen any mention of the 
  224.     #  next five URL types yet, but what the heck.....
  225.   :ssh,
  226.   :telnet-ssl,
  227.   :s5telnet,
  228.   :ktelnet,
  229.   :srp-telnet,
  230.     
  231.     #  Back to reality:
  232.   :tn3270,
  233.   :tn5250,
  234.   :default,
  235.     #  included for future generalization of this script
  236.     echo  \%r protocol currently not supported.
  237.     ask  \%z  Press enter to continue
  238.     quit
  239.     .\%c = {pty \%r   }
  240.     .\%s :=  {  }
  241.     break
  242. }
  243. # Finished handling URL protocol specific stuff
  244.  
  245.  
  246. # Check to see if a directory/filename is on the end of the URL
  247. # indicates that this is a particular file to be downloaded from an IKSD:
  248.  
  249.   .\%i := /\Flop(\%a,/)          #  i holds the path/filename
  250.   .\%a := \Freplace(\%a,\%i)     #  a holds usrid:password@host.domain:port
  251.  
  252. # extract filename:
  253.   .\%f := \Freplace(\%i,\Fstripx(\%i,/),)   #  f has the directory removed
  254.   .\%f := \Fltrim(\%f,/)                    #  now f has any '/' trimmed off
  255.   .\%q := \Freplace(\%i,\%f,)               #  q holds just the path name
  256.  
  257.  
  258.  
  259. # Now handle 'User:password' part of URL:
  260.  
  261. # find  the '@'s location in the URL:
  262.   .\%t := \Findex(@,\%a)
  263. #  Definitly set defaults for user and password:
  264.   .\%u := { }
  265. set login userid
  266.   .\%w := { }
  267.  
  268. if > \%t 0 {
  269.   #  extract and clean up the 'usrid:password':
  270.   .\%u := \Fstripx(\%a,@)
  271.   #  extract and clean up the 'host.domain:port':
  272.   .\%a := \Flop(\%a,@)
  273.   .\%a := \Flop(\%a,@)    #  the ftp two '@' case
  274.   # is there a password?
  275.   .\%t := \Findex(:,\%u)
  276.   #  Now seperate the user id from the password if present:
  277.   if > \%t 0 {
  278.     .\%w := \Flop(\%u,:)
  279.     .\%u := \Fright(\%u,\%t)
  280.     .\%u := \Ftrim(\%u,:)
  281.   }
  282.   # For kermit:
  283.   set ftp autologin on
  284.   set ftp user \%u \%w
  285.   set login userid \%u
  286. }
  287. # Finished extracting user/password
  288.  
  289.  
  290. # Now handle any port part of the URL:
  291.   .\%p := { }
  292. # Is there a port specified?
  293.   .\%t := \Findex(:,\%a)    #    'host.domain:port' are divided at \%t index
  294.  
  295. # Now, if a port was specified:
  296. if > \%t 0  {
  297.   .\%p := \Flop(\%a,:)
  298.   .\%a := \Freplace(\%a,\%p,)
  299.   if equal \%p kermit  .\%p := 1649
  300.   .\%a := \Ftrim(\%a,:)
  301.   if equal \%r telnet  if equal \%p 1649  -
  302.     if not equal {\%i} {} {
  303.     #  this case is really not interactive, but in fact IKSD
  304.     #  to a specific file
  305.     .\%r := IKSD
  306.   }
  307. }
  308. # End of handling port number
  309.  
  310.  
  311. # Handle HTTP/interactive selections here:
  312.  
  313. # Make this script do double duty, by putting the following line
  314. # in the printer setup part of the your Lynx configuration file.
  315. # Then you can pass the URL of the currently viewed page
  316. # (not just the currently active link) to other browsers:
  317.  
  318. #  PRINTER:View URL with other browser:exec /path/lynxbooster.ksc ${LYNX_PRINT_URL}:TRUE
  319.  
  320. # (hit the 'p' key, and select 'View URL with other browser' to bring
  321. # up this menu.)
  322. # See the Lynx man pages for information on enviromental variable
  323. # LYNX_PRINT_URL.
  324.  
  325. if equal \%r http  {
  326.  
  327.   #    This part should be adjusted for whatever suplemental
  328.   #    HTTP tools you want to use.
  329.  
  330.   if equal {\%f} {}    .\%f := \%a
  331.   clear screen
  332.   #  -- try to keep this screen formating/menu simple and uncluttered
  333.   :wwwchoice
  334.   echo 
  335.   echo To connect to \%a\, choose an alternate browser:
  336.   echo  
  337.  
  338.   #  most of these are frame-capable browsers
  339.   #  (Lynx barely handles frames.):
  340.  
  341.   echo {  N  Netscape}
  342.   echo {  W  w3m}
  343.   echo {  L  Links}
  344.   echo {  D  Debris}
  345.  
  346.   #  Warning about Debris:  I'm certain it will be great when complete,
  347.   #  but it is a work in progress.  My experience is that
  348.   #  if you notice this script flashing on the screen and aborting
  349.   #  before you can do anything, you may of called Debris once too often.
  350.   #  :-)
  351.  
  352.   #  and a few methods of dumping files/directories
  353.   #  in background:
  354.  
  355.   echo {  Y  Lynx/dump in background}
  356.   echo {  R  Wget/recurse in background}
  357.   echo {  X  Exit back to Lynx}
  358.   #  echo {  E Etc.........}
  359.  
  360.   #  Could have Lynx using some drasticly different configuration
  361.   #  file listed in here, maybe special provisions for handling
  362.   #  cookies.
  363.   
  364.  
  365.  
  366.  
  367.   echo  
  368.   ask \%b {Alternate browser choice: }
  369.   echo  \%b
  370.  
  371.   switch \%b  {
  372.  
  373.     :N,  exec  netscape \%d
  374.          break
  375.  
  376.     :W,  exec  w3m  -M  -F -no-cookie -no-mouse   \%d
  377.          break
  378.   
  379.     :L,  exec  links   \%d
  380.          break
  381.   
  382.     :D,  exec  debris   \%d
  383.          break
  384.   
  385.     :Y,  run  lynx -source  \%d  >  \%f  &
  386.          #  May want to put cookie handling capabilities
  387.          #  with the above command
  388.          #  or maybe nohup this to direct the output
  389.          #  away from the screen
  390.          break
  391.   
  392.     :R,  run  wget -D \%a -P \v(download) -np -brkl5  \%d
  393.          break
  394.          # -D \%a          - restricted to  \%a domain
  395.          # -P \v(download) - put in download directory
  396.          # -np             - no parent directories
  397.          # -b              - go to background
  398.          # -r              - download recursively
  399.          # -k              - 'konvert' to relative links
  400.          # -l5             - limit to just 5 levels of recursion
  401.   
  402.     :X,  break       #  exit back to Lynx
  403.  
  404.   
  405.     :default,  echo {Invalid choice, try again}, goto wwwchoice
  406.   }
  407.   quit
  408.  
  409. }
  410. # end of HTTP/interactive selection 
  411.  
  412. if not equal {\%p} { }  .\%p := :\%p
  413. else .\%p := 
  414.  
  415.  
  416. #  If a specific directory/file is defined to retreive, hop to
  417. #  non-interactive options
  418. #  if not equal {\%i} {}  forward getafile
  419. #   temp (X) :  set ftp autologin on
  420. if not equal {\%f} {}  forward getafile
  421.  
  422.  
  423. # No file is specified
  424. # Assumption is that they expect you to browse
  425. # directory for whatever reason.
  426. if equal  \%r ftp  {
  427.   if not equal {\%w} { }   exec  FTP  -u \%u -P \%w -S  -D  \%q  \%a  \%p
  428.   if not equal {\%u} { }   exec  FTP  -u \%u        -S  -D  \%q  \%a  \%p
  429.                            exec  FTP  -A            -S  -D  \%q  \%a  \%p
  430. }
  431.  
  432.  
  433. if equal \%r iksd  {
  434.   if equal {\%w} { }  .\%w := \v(userid)@\v(host)
  435.   if equal {\%u} { }  .\%u := anonymous
  436.  
  437.   #  It seems to work best for me if normal initialization
  438.   #  is carried out before making an IKSD connection
  439.   take ~/.kermrc
  440.  
  441.   set network type tcp
  442.   set host  telnet://\%a\%p
  443.   remote login \%u \%w
  444.   remote cd \%i
  445.   end
  446. }
  447.  
  448.  
  449. #  Parts from here to ':modechoice' will probably need modification
  450. #  if any protocols that actually use pty/pipe external
  451. #  programs are used.
  452.  
  453.  
  454.  
  455. # So if a password was given:
  456. if not equal {\%w} { } {
  457.   echo {  Remember, in the URL}
  458.   echo {  the fools gave you this password: \%w}
  459.   ask \%z  Press any key to continue
  460. }
  461.  
  462.  
  463. # If a userid was given:
  464. if not equal {\%u} { } {
  465.   exec kermit -M \%u \%r://\%a\%p\%i
  466.   forward  the_end
  467. }
  468.  
  469.  
  470. # If no userid was part of the URL:
  471.  
  472. exec kermit  -J \%r://\%a\%p\%i
  473. forward  the_end
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482. #  Here handle getting a specific file:
  483. :getafile
  484.  
  485. clear screen
  486. #  -- try to keep this screen formating/menu simple and uncluttered
  487. :modechoice
  488. echo 
  489. echo To connect to \%a and retreive \%i, 
  490. echo using \%r protocol, choose a mode:
  491. echo  
  492. echo {  F  Foreground - 'I like to watch'}
  493. echo {  B  Background - 'My time is precious'}
  494. echo {  X  Exit       - 'I need to do something else'}
  495. echo  
  496. echo d is \%d
  497. echo r is \%r
  498. ask \%b {Job mode choice: }
  499. echo  \%b
  500.  
  501. switch \%b  {
  502.   :f,  if equal \%r ftp  {
  503.          exec FTP   \%d   
  504.               #  Using C-Kermit 7.1 FTP personality
  505.          break
  506.        } 
  507.        exec  kermit \%d
  508.        #  Use IKSget if using older version, pre-7.1
  509.        #  instead of kermit here.
  510.        #  May want to nohup this to control output 
  511.        break
  512.   :b,  if equal \%r ftp  {
  513.          run  FTP   \%d  &    #  Again, Using C-Kermit 7.1's FTP personality
  514.          #  May want to nohup this to control output 
  515.          #  otherwise may need to ^L to refresh screen as
  516.          #  messages arrive from the background
  517.          break
  518.        }
  519.        run  kermit \%d &
  520.        #  Again, use IKSget if using older version, pre-7.1
  521.        #  instead of kermit here.
  522.        #  ditto the above ftp comments
  523.        break
  524.   :x,  break
  525.   :default,  echo {Invalid choice, try again}, goto modechoice
  526. }
  527.  
  528. forward the_end
  529.  
  530.  
  531. :the_end
  532.  
  533. echo Exiting lynxbooster.ksc
  534. quit
  535.  
  536.  
  537. Thanks to everyone at the Kermit center for the help they've
  538. provided many times.
  539.  
  540. Regards,
  541. Dallas E. Legan II  
  542. l  \  d
  543.  e  \  a
  544.   g  \  l
  545.    a  \  l
  546.     n  \  a
  547.      i  \  s
  548.       i  \  i
  549.        @  \  @
  550.         s  \  k
  551.          u  \  i
  552. Parse     r  \  n
  553. this       f  \  c
  554. SpamBots!   r  \  y
  555.              e  \  b
  556.               e  \  .
  557.                .  \  c
  558.                 c  \  o
  559.                  o  \  m
  560.                   m